package com.yangjun.controller.report;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.yangjun.service.report.ActivePackageReprotExportService;
import com.yangjun.vo.report.ActivePackageReportExportVO;

@RestController
@RequestMapping(value="/excel/acPackage")
public class ActivePackageController {
	@Autowired
	private ActivePackageReprotExportService activePackageReprotExportService;
	
	@ResponseBody
	@RequestMapping("/getDeminsion")
	public Object getDeminsion(@RequestParam(value="reportid")String reportid,@RequestParam(value="userid")String userid){
		return activePackageReprotExportService.getDeminsion(reportid,userid);
	}
	@ResponseBody
	@RequestMapping("/queryDataByReportId")
	public Object queryDataByReportid(@RequestParam(value="reportid")String reportid){
		return activePackageReprotExportService.queryData(reportid);
	}
	@ResponseBody
	@RequestMapping("/queryData")
	public Object queryData(ActivePackageReportExportVO apreVo){
		
//		String ordersource = "1,2,3,4,13,14,15,16,21,25";
//		apreVo.setOrdersource(ordersource.split(","));
//		String activeType = "优惠券,免运费,区域免运费,单品免运费,套餐(搭配),客户等级免邮费,手动优惠,支付类型满金额减,满数量减,满数量加价购,满数量特价,满数量赠品,满数量送优惠券,满金额减,满金额加价购,满金额赠品,满金额送优惠券,限时限量打折,限时限量特价";
//		apreVo.setActiveType(activeType.split(","));
//		apreVo.setIsWhole("是,否".split(","));
//		apreVo.setIsStopUse("是,否".split(","));
//		apreVo.setIsVerify("是,否".split(","));
//		apreVo.setIsTempletShow("是,否".split(","));
//		apreVo.setIsLabelShow("是,否".split(","));
//		apreVo.setStartBeginDate("2017-09-15");
//		apreVo.setStartEndDate("2017-09-21");
//		String target = "iswhole,isstop,ischeck,istemplateshow,istagshow,fullqty,fullamount,disamt,starttime,endtime,prmdesc,prmtypename,prmflagname,kitsubtitle,kitprice,kitremark,ordersource,cusgradename,warecode,warename,department,iskeyware,isdetailshow,price,specialprice,kitvalue,marketingcosts,warecodeGift,warenameGift,singleqty,dataDate,sourcename,qty,invoiceamount,orderNum,acDisamt,acOrdercostGift,acMarketingcosts,acTotaltimes,acConponCntUsed";
//		apreVo.setTarget(target.split(","));
		return activePackageReprotExportService.queryData(apreVo);
	}
	
	@ResponseBody
	@RequestMapping("/addReport")
	public Object addReport(ActivePackageReportExportVO apreVo){
//		上传附件ID：uploadFileId
		
//		apreVo.setUserid("18");
//		apreVo.setUsername("yj");
//		apreVo.setUserrealname("杨俊");
//		apreVo.setSearchName("activeCode");
//		apreVo.setReportName("活动套餐-测试1");
//		
//		String ordersource = "1,2,3,4,13,14,15,16,21,25";
//		apreVo.setOrdersource(ordersource.split(","));
//		String activeType = "优惠券,免运费,区域免运费,单品免运费,套餐(搭配),客户等级免邮费,手动优惠,支付类型满金额减,满数量减,满数量加价购,满数量特价,满数量赠品,满数量送优惠券,满金额减,满金额加价购,满金额赠品,满金额送优惠券,限时限量打折,限时限量特价";
//		apreVo.setActiveType(activeType.split(","));
//		apreVo.setIsWhole("是,否".split(","));
//		apreVo.setIsStopUse("是,否".split(","));
//		apreVo.setIsVerify("是,否".split(","));
//		apreVo.setIsTempletShow("是,否".split(","));
//		apreVo.setIsLabelShow("是,否".split(","));
//		apreVo.setStartBeginDate("2017-09-15");
//		apreVo.setStartEndDate("2017-09-21");
//		apreVo.setFinishBeginDate("");
//		apreVo.setFinishEndDate("");
//		String target = "iswhole,isstop,ischeck,istemplateshow,istagshow,fullqty,fullamount,disamt,starttime,endtime,prmdesc,prmtypename,prmflagname,kitsubtitle,kitprice,kitremark,ordersource,cusgradename,warecode,warename,department,iskeyware,isdetailshow,price,specialprice,kitvalue,marketingcosts,warecodeGift,warenameGift,singleqty,dataDate,sourcename,qty,invoiceamount,orderNum,acDisamt,acOrdercostGift,acMarketingcosts,acTotaltimes,acConponCntUsed";
//		apreVo.setTarget(target.split(","));
		return activePackageReprotExportService.addOrUpdateReport(apreVo);
	}
	
	
	@ResponseBody
	@RequestMapping("/addDownloadTaskByReportId")
	public Object addDownloadTaskByReportId(@RequestParam(value="reportid")String reportid,HttpServletRequest request){
		return activePackageReprotExportService.addDownloadTask(reportid,request);
	}	
	
	@ResponseBody
	@RequestMapping("/addDownloadTask")
	public Object addDownloadTask(ActivePackageReportExportVO apreVo,HttpServletRequest request){
		return activePackageReprotExportService.addDownloadTask(apreVo,request); 
	}
}
